import routes from '@/router/routes';

export const fetchAuths = (): Promise<any> => {
  return new Promise(resolve => {
    setTimeout(() => {
      resolve({
        data: {
          buttonKeys: {},
          menuTree: routes,
        },
      });
    }, 1000);
  });
};

/**
 * 获取当前登录用户信息
 * @returns 返回用户信息
 */
export const fetchUserInfo = (): Promise<any> => {
  return new Promise(resolve => {
    setTimeout(() => {
      resolve({
        code: 0,
        data: {
          nickname: '测试001',
          username: 'test001',
        },
      });
    }, 1000);
  });
};

export const logout = (): Promise<unknown> => {
  return new Promise(resolve => setTimeout(() => resolve(null), 1000));
};

export interface LoginParams {
  // 密码
  password: string;
  // 账号
  username: string;
}

/**
 * 登录
 * @param params LoginParams
 * @returns 返回token和用户信息
 */
export const login = (values: LoginParams): Promise<any> => {
  return new Promise(resolve => {
    setTimeout(() => {
      resolve({
        code: 0,
        data: {
          token: 'ASKL_ASJKLASLASAKLASJKL',
          userInfo: {
            nickname: '测试001',
            username: values.username,
          },
        },
      });
    }, 1000);
  });
};
